@extends('layouts.mobile_main')

@section('title', '登录')

@section('resources')
    @parent
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <link rel="stylesheet" href="{{ env('CSS_DOMAIN') }}/css/public.css?v={{env('CSS_VERSION')}}">
    <script src="{{ env('JS_DOMAIN') }}/js/adaptation.js?v={{env('JS_VERSION')}}"></script>
@endsection

@section('content')
<header class="entry oh">
    
	<a class="fl oh" href="javascript:history.go(-1);"><img class="fl" src="{{env('IMAGE_DOMAIN')}}/images/back_g.png" alt=""></a>
	
</header>
<section class="entry_center">
	<div class="entry_headpic pr">
		<img src="{{env('IMAGE_DOMAIN')}}/images/login_logo.png" alt="">
	</div>
	<p class="tc co_gray entry1_proving">请输入您的手机 <span class="co_violet">{{$mobile}}</span> 收到的6位验证码</p>
	<form method="post" action="/mobile/login/submit" class="pr">
		<span class="fz_48 co_gray entry1_0">验证码</span>
		<span style="width: 3rem;" class="fz_48 co_gray entry1_1" id="retry_send">60秒</span>
		<input type="hidden" name="mobile" value="{{$mobile}}" />
		<input style="width: 8.6rem;padding-right: 1rem;" class="fz_48 tc" id="entry1_idcode" name='code' type="text" placeholder="请填写6位验证码" maxlength="6" onpropertychange="check_code();" oninput="check_code();" autocomplete="off">
		<input type="submit" value="登录" id="entry_sub">
	</form>

    <!-- 返回消息 -->
    @if(isset($message))
        <div style="font-size: 0.4rem;text-align: center;color: #FF2E2F;">{{$message}}</div>
    @endif
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
	    window.onresize=function(){
		    pagesp();
	    }
	    function check_code(){
	    	var neirong=$("#entry1_idcode").val();
	    	if(neirong!=0){
	    		$("#entry_sub").css("background-color","#9a54c6");
	    	}else{
	    		$("#entry_sub").css("background-color","#ccc");
	    	}
	    }
	    if(/msie/i.test(navigator.userAgent))    //ie浏览器   
	        {document.getElementById('entry1_idcode').onpropertychange=check_code   
	    } else{//非ie浏览器，比如Firefox   
	        document.getElementById('entry1_idcode').addEventListener("input",check_code,false);   
	    }   
	    $(function(){
		    var paysu_outer_h=$(window).height();
		    $(".paysu_outer").css({"min-height":paysu_outer_h});
		    var timer=null,seconds=60;
		    function countdown(){
		    	seconds--;
		    	if(seconds<0){
		    		$("#retry_send").html("语音验证码");
		    		$("#retry_send").css("color","#9a54c6");
		    		seconds=0;
		    		clearInterval(timer);
		    		return false;
		    	}
		    	$("#retry_send").html(seconds+"秒");
		    	$("#retry_send").css("color","#808080");
		    }
		    timer=setInterval(countdown,1000);
		    $('#retry_send').click(function() {
		        var mobile = $("input[name='mobile']").val();
		        if($('#retry_send').html() == "语音验证码"){
		        	seconds=60;
		        	timer=setInterval(countdown,1000);
		        	$.ajax({
		                url :"/mobile/captcha/get",
		                type:'POST',
		                data : {'mobile':mobile},
		                dataType:'json',
		                async:false,
		                success:function(data){
		                    if (data.status == "success") {
		                        alert(data.message);
		                    } else {
		                        alert(data.message);
		                    }
		                }
		            });
		        }
		    });
	    })
		    
    </script>
@endsection